#{extends 'organization.html' /}
#{set title: 'Lead Resign'/}
<h1 class="viewTitle">Organization Lead Resign</h1>
<div class="viewContent">  

<link rel="stylesheet" type="text/css" href="@{'/public/stylesheets/jquery.autocomplete.css'}" />
<script type="text/javascript" src="@{'/public/javascripts/jquery.autocomplete.js'}"></script>
#{if cancelRequest == -1}
<script>
alert("Sorry you are not authorized to view this page");
</script>
<h2>Sorry you are not authorized to view this page</h2>
#{/if}
#{elseif cancelRequest == 1}
<h2>Sorry but you already have sent a similar request before:(</h2>
<h3>
<br/>
Click this button if you want to cancel the old request and make a new one:-
</h3>
#{form @RequestController.cancelOrganizationLeadResignRequest(orgID)}
<div class="formEntry">
<input type = "submit" value = "Cancel old request"/>
<div class="clear"></div>
</div>
#{/form}
#{form @Browse.viewOrganization(orgID)}
<div class="formEntry">
<input type="submit" value="Back to Organization page" />
</div>
#{/form}
#{/elseif}
#{else}

#{ifErrors}
	<div class="error">
 <h4>Oops</h4>
   #{errors}
       <li>${error}</li>
   #{/errors}
   </div>
#{/ifErrors}


<script>
  $(document).ready(function(){
    var data =  "${userNamesAndEmails}".split(", ")
    data[0] = data[0].substring(1,data[0].length)
    data[data.length-1] = data[data.length-1].substring(0,data[data.length-1].length-1)
  $("#nameOrEmail").autocomplete(data);
  });
  </script>
  <h3>Please enter the username/email of 
  the user you want to take over your position</h3>
  #{form @RequestController.sendOrganizationLeadResignRequest(orgID)}
            <div class="formEntry">
			<div class="formLabel">
			<label> Enter username/email </label>
			</div>
            <input name="nameOrEmail" id="nameOrEmail" required="true" />
            <input type = "submit" value = "Submit Request"/>
            <div class="clear"></div>
			</div>
  #{/form}
  #{form @Browse.viewOrganization(orgID)}
<div class="formEntry">
<input type="submit" value="Back to Organization page" />
</div>
#{/form}
#{/else}
</div>